<style scoped lang="less">
.elscrollbarmyself ::v-deep{
 .el-scrollbar__wrap{
  overflow-x: hidden;
 }
}
</style>
<template>

  <el-form
      ref="formref"
      :model="formData"
      label-width="auto"
      :inline="true"
  >
    <el-form-item
        label="id" prop="id" align="center">
      <div slot="label"><span>id</span></div>
      <el-input v-model="formData['id']" clearable size="mini" style="width:120px" />
    </el-form-item>
    <el-form-item
        label="name" prop="name" align="center">
      <div slot="label"><span>name</span></div>
      <el-input v-model="formData['name']" clearable size="mini" style="width:120px" />
    </el-form-item>
    <section>
      <el-form-item
          label="desccontent" prop="desccontent" align="center">
        <div slot="label"><span>desccontent</span></div>
        <section style="border: 1px solid #ddd;">
          <el-scrollbar style="height: 520px;"
                        :native="false"
                        :noresize="false"
                        class="elscrollbarmyself"
          >
               <pre v-text="formData['desccontent']" ref="desccontentref"
                    type="textarea" :rows="20"
                     size="mini" style="width:666px;text-align: left;overflow: hidden"
                    :contenteditable="true"
               >        </pre>
          </el-scrollbar>
        </section>

      </el-form-item>
    </section>


  </el-form>
</template>
<script>
import axios from 'axios';
import { formMethod, PageData } from '@/utils/formcommon';
import { openLayer } from '@/utils/layerdialog/layerdialog';
import { alertWithPayload } from '@base/utils';
import { lodashFillData } from '@/utils/lodashUtil';
import { deepClone } from '@/utils';
import { tbGerenrateTemplate } from '@/views/manage/tbGerenrateTemplate/tbGerenrateTemplate.json';


export default {
  data() {
    return {
      total: 0,
      formData: {
        ...deepClone(tbGerenrateTemplate),
        ...PageData,
      },

    };
  },
  methods: {
    ...formMethod,
    async initByDialog(_data) {
      if (_data?.row?.id) {
        var result = await axios.get(`/api/tb_gerenrate_template/getbyid?id=${_data?.row?.id}`, { ...this.queryParams }).then(res => res.data);
        var _data2 = result?.data;
        lodashFillData(this.formData, _data2);
        console.log('=>[_data2]', _data2);
      }
    },
    async submitByDialog() {
      //validate
      //data operation
      //ajax 提交
      var url = '/api/tb_gerenrate_template/add';
      if (this.formData?.id) {
        url = '/api/tb_gerenrate_template/update';
      }
      var result = await axios.post(url, {
        ...this.formData,
        desccontent: this.$refs['desccontentref']?.innerText,
      }).then(res => res.data);
      alertWithPayload(result);
      return result;
    },
  },
};
</script>
